#r "nuget:System.Drawing.Common/6.0.0"
using System.Drawing;
using System.Drawing.Imaging;

//Bitmap对象转base64
private string GetImageURI(Bitmap bmp)
{
    using MemoryStream ms = new MemoryStream();
    bmp.Save(ms, ImageFormat.Jpeg);
    var arr = ms.ToArray();
    string base64 = @"data:image/jpeg;base64," + Convert.ToBase64String(arr);
    return base64;
}

//Jpeg文件转base64
private string GetImageURI(string jpgFile)
{
    return @"data:image/jpeg;base64," +
        Convert.ToBase64String(File.ReadAllBytes(jpgFile));
}

//Bitmap bmp = (Bitmap)Bitmap.FromFile(@"e:\123\02.jpg");
//GetImageURI(bmp).Length


string path = @"e:\123\02.jpg";
string base64 = GetImageURI(path);

base64.Length